package cn.liziguo.tank.util;

/**
 * @author Liziguo
 * @date 2022/7/14 14:17
 */
public class LocalTimer {

    private long lastTime;

    public LocalTimer() {
    }

    public LocalTimer(long lastTime) {
        this.lastTime = lastTime;
    }

    /**
     * 判断距离上一次捕获事件是否达到millis毫秒
     *
     * @param millis 毫秒
     * @return true or false
     */
    public boolean elapsed(long millis) {
        return System.currentTimeMillis() - lastTime >= millis;
    }

    /**
     * 捕获
     */
    public void capture() {
        lastTime = System.currentTimeMillis();
    }

}
